package com.ming.sportdemo.controller;


import com.alibaba.fastjson.JSON;
import com.ming.sportdemo.bean.User;
import com.ming.sportdemo.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.xml.transform.Result;
import java.util.HashMap;

@RestController
public class RegisterController {
    @Autowired
    UserDao userDao;
    @RequestMapping("/register")
    public String register(@RequestBody User user){
        String flag="error";
        HashMap<String,Object> res=new HashMap<>();
        if (user!=null){
            userDao.addUser(user);
            flag="ok";
        }
        res.put("flag",flag);
        res.put("data",user);
        return JSON.toJSONString(res);
    }
}
